#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename	:  ping_ethtool
# Version	:  2.0
# Date		:  2023/12/21
# Author	:  yaoxiyao
# Email		:  yaoxiyao@kylinos.com.cn
# History	:
#              Version 1.0, 2023/12/21
# Function	:  支持网络链路故障检测、链路事件通知和链路状态查询
# Out		:
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

# 测试主题
Title_Env_LTFLIB="网络管理-支持网络链路故障检测、链路事件通知和链路状态查询"

## TODO : 个性化,初始化
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestInit_LTFLIB() {
    return $TPASS
}

## TODO : 清理函数
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestClean_LTFLIB() {
    return $TPASS
}

## TODO : 测试用例集
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
Testsuite_LTFLIB() {
    testcase_1
    return $TPASS
}

## TODO :  ping通内网节点,查看网卡信息
testcase_1() {
    #local netip="10.0.0.66"
    ping -c 4 localhost
    CommRetParse_LTFLIB "ping -c 4 localhost"
    #ping -c 4 "${netip}"
    #CommRetParse_LTFLIB "ping -c 4 ${netip}"

    local eth=($(ip a | grep "UP group" | awk -F ':' '{print $2}'))
    ethtool "${eth[0]}"
    CommRetParse_LTFLIB "ethtool ${eth[0]}"

    ethtool -S "${eth[0]}"
    CommRetParse_LTFLIB "ethtool -S ${eth[0]}"
}

#----------------------------------------------#

source "${LIB_LTFLIB}"
Main_LTFLIB $@
